Coding Assignment2, Arrays and Functions
This assignment is about finding the sum and average of
array called numbers.
0. First you will need to create assignment2.html file,
assignment2.js file
1.Inside js file create numbers array
2. The values of the array should be 5, 3, 6, 7, 5, 3.
3. Name the first function sum and the second average
4. **** Hint **** Use for loop in order to access the array
elements. Also sum function should be passed one argument that is the numbers array
5. Create a function average without any arguments and inside calculation average = total/length;
6. Console log both the sum and average outside the function
Output should be look like this:
Sum of an array is: 29
Average of an array is: 4.833333333333333
6. Now modify the values of the numbers array and put only
two 0 values 0,0
7. Now modify the console log outside the function with
if condition to check if the of the functions sum and average are 0
The output should be like this:
Sum of an array is: 0
Average of an array is: 0